<template>
    <div class="preview-PDF" v-if="pdfURL">
       <div class="preview__main">
            <iframe
                :src="pdfURL"
                type="application/x-google-chrome-pdf"
                width="100%"
                height="100%"
                id="preview-PDF"
            />
       </div>
        <i
            class="close iconfont icon-circleClose"
            @click="close"
        />
    </div>
</template>

<script>
export default {
  props: {
    src: {
      type: String,
      default: ''
    }
  },
  data () {
    return {
      pdfURL: ''
    }
  },
  watch: {
    src: {
      handler (newVal) {
        this.pdfURL = newVal
      },
      immediate: true
    }
  },
  methods: {
    close () {
      this.$emit('update:src', '')
      this.$emit('close', false)
    }
  }
}
</script>

<style lang="less" scoped>
.preview-PDF{
    position: fixed;
    top: 0;
    left: 0;
    z-index: 9991;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100vh;
    background-color: rgba(0,0,0,.6);
    iframe{
        border: none;
    }
    .preview__main{
        width: 80%;
        height: 94%;
    }
    .close{
        font-size: 40px;
        position: absolute;
        right: 20px;
        top: 20px;
        color:#fff;
        cursor: pointer;
    }
}
</style>
